<?php

class sp_select {

    /**
     * 
     * @param type $table_name : tên bảng 
     * @param type $name_fiel : tên trường  điều kiện 
     * @param type $dk :  tên của điều kiện để truy xuất 
     * @param type $t1 : cần xuất ra màn hình cái j 
     */
    function select_1($table_name, $name_fiel, $dk, $t1) {
        $result = mysql_query("select * from $table_name where $name_fiel='".$dk."'");
        @$row1 = mysql_fetch_array($result);
        echo $row1[$t1];
    }
    
    function getCurrentPageURL() {
    $pageURL = 'http';
    if (!empty($_SERVER['HTTPS'])) {if($_SERVER['HTTPS'] == 'on'){$pageURL .= "s";}} 
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
        $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}

    function selectAll($table_name) {
        return mysql_query("select * from $table_name");
    }
    
    function Tselect($table_name,$t1){
        $result = mysql_query("select * from $table_name"); 
        mysql_fetch_array($result);
    }

    function Re_select($table_name, $name_fiel, $dk, $t1) {
        $result = mysql_query("select * from $table_name where $name_fiel='".$dk."'");
        @$row1 = mysql_fetch_array($result);
        return $row1[$t1];
    }

    function DeleteAll($table_name, $name_fiel, $dk) {
        $result = mysql_query("DELETE FROM $table_name where $name_fiel='".$dk."'");
        ?>
        <script >window.location.href = 'index.php?content=xoa_tour'</script>
        <?php

    }

    function DeleteAll1($table_name, $name_fiel, $dk) {
        return mysql_query("DELETE FROM $table_name where $name_fiel='".$dk."'");
    }
    
    function UpdateAll($table_name, $name_fiel, $dk,$name_fiel_dk,$dk1){
        return mysql_query("update $table_name set $name_fiel=$dk where $name_fiel_dk='".$dk1."'");        
    }
    
    function selected($value, $v_compare){
    if($value==$v_compare)
        echo 'selected="selected"';
    else
        echo '';
    }

}
?>